package com.company.card_service.config.loginInterceptConfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class LoginMvcConfigurerAdapter implements WebMvcConfigurer {

    @Resource
    private RedisTemplate redisTemplate;

    @Resource
    private UserLoginInterceptor userLoginInterceptor;

    @Resource
    private AdminLoginInterceptor adminLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加自定义拦截器，设置路径
        registry.addInterceptor(userLoginInterceptor).addPathPatterns("/api/**");
        registry.addInterceptor(adminLoginInterceptor).addPathPatterns("/admin/**");
    }
}
